;(function($) {
	$.jqValidator = $.jqValidator || {};
	$.extend($.jqValidator,{
		/**
		 * 校验表单
		 */
		validateForm : function(selector) {
			var bol = true,foscusElm = false;
			var validateMsg = "";
			$(selector).find('input,select,textarea').each(function(ind,elm){
				var $elm = $(elm),_val = $elm.val();
				var validateRulesText = $elm.attr('validateRules');
				if(validateRulesText){
					var validateRules = $.parseJSON(validateRulesText);
					if(!$.isEmptyObject(validateRules) && $.isPlainObject(validateRules)){
						for(var key in validateRules) {
								if(key !="fieldName") {
									bol = $elm.jqV(key,validateRules,_val);
								}else {
									continue;
								}
									
							if(!bol){
								validateMsg += $elm.data($.jqValidator.validateMsgKey)[key].msg+ "\n";
								$.jqValidator.toggleValidateClass($elm,true);
								if(!foscusElm)
								$elm.focus();
								foscusElm = true;
							}
						}
						
					}
				}
			});
			if(validateMsg.length>0)
			alert(validateMsg);
			return bol;
		}
	});
})(jQuery);